#ifndef _FRACTAL_fvector_H_
#define _FRACTAL_fvector_H_


template <class CoordType, int Dim>
class FVector
{
public:
    static const CoordType dim = Dim;
    typedef CoordType coord_type;

    virtual coord_type
    get_coord(int n) const = 0;

    virtual ~FVector(void)
    { }
};


template <class CoordType>
class FVector2Dim: public FVector<CoordType, 2>
{
public:
    CoordType x, y;

    FVector2Dim(void):
	x(0.0), y(0.0)
    { }

    FVector2Dim(CoordType x):
	x(x), y(x)
    { }

    FVector2Dim(CoordType x, CoordType y): 
	x(x), y(y)
    { }

    virtual CoordType 
    get_coord(int n) const
    {
	switch (n) {
	case 0: return x;
	case 1: return y;
	default: return 0;
	}
    }
};


typedef FVector2Dim<double> FVector2d;


template <class CoordType>
class FVector3Dim: public FVector<CoordType, 3>
{
public:
    CoordType x, y, z;

    FVector3Dim(void):
	x(0), y(0), z(0)
    { }

    FVector3Dim(CoordType x):
	x(x), y(x), z(x)
    { }

    FVector3Dim(CoordType x, CoordType y, CoordType z): 
	x(x), y(y), z(z)
    { }

    virtual CoordType 
    get_coord(int n) const
    {
	switch (n) {
	case 0: return x;
	case 1: return y;
	case 2: return z;
	default: return 0;
	}
    }
};


typedef FVector2Dim<double> FVector3d;


#endif  // _FRACTAL_FVECTOR_H_
